
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>关于AppleScript脚本语言的一些使用总结 · Summary</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism-xonokai.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                        <b>1.1.</b>
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../workflows/">
            
                <a href="../workflows/">
            
                    
                        <b>1.2.</b>
                    
                    workflows相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../workflows/iOS开发如何给自己的App增加捷径自定义拓展.html">
            
                <a href="../workflows/iOS开发如何给自己的App增加捷径自定义拓展.html">
            
                    
                        <b>1.2.1.</b>
                    
                    iOS开发如何给自己的App增加捷径自定义拓展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../workflows/如何制作一个手机上的Github图床捷径workflow.html">
            
                <a href="../workflows/如何制作一个手机上的Github图床捷径workflow.html">
            
                    
                        <b>1.2.2.</b>
                    
                    如何制作一个手机上的Github图床捷径(workflow)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                        <b>1.3.</b>
                    
                    AppleScript相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="关于AppleScript脚本语言的一些使用总结.html">
            
                <a href="关于AppleScript脚本语言的一些使用总结.html">
            
                    
                        <b>1.3.1.</b>
                    
                    关于AppleScript脚本语言的一些使用总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.html">
            
                <a href="为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.html">
            
                    
                        <b>1.3.2.</b>
                    
                    为Mac自带的AppleScript脚本编辑器增加代码注释快捷键
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="say指令让Mac说话.html">
            
                <a href="say指令让Mac说话.html">
            
                    
                        <b>1.3.3.</b>
                    
                    say指令让Mac开口说话
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../Shell/">
            
                <a href="../Shell/">
            
                    
                        <b>1.4.</b>
                    
                    Shell相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../Shell/我折腾的shell笔记.html">
            
                <a href="../Shell/我折腾的shell笔记.html">
            
                    
                        <b>1.4.1.</b>
                    
                    我折腾的shell笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../Shell/关于Xcode12静态库打包的一些心得.html">
            
                <a href="../Shell/关于Xcode12静态库打包的一些心得.html">
            
                    
                        <b>1.4.2.</b>
                    
                    关于Xcode12静态库打包的一些心得
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../Shell/剪贴板的使用.html">
            
                <a href="../Shell/剪贴板的使用.html">
            
                    
                        <b>1.4.3.</b>
                    
                    剪贴板的使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../Shell/指定入参的使用.html">
            
                <a href="../Shell/指定入参的使用.html">
            
                    
                        <b>1.4.4.</b>
                    
                    指定入参的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../git-about/">
            
                <a href="../git-about/">
            
                    
                        <b>1.5.</b>
                    
                    git相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../git-about/git使用技巧总结.html">
            
                <a href="../git-about/git使用技巧总结.html">
            
                    
                        <b>1.5.1.</b>
                    
                    git使用技巧总结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >关于AppleScript脚本语言的一些使用总结</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x5173;&#x4E8E;applescript&#x811A;&#x672C;&#x8BED;&#x8A00;&#x7684;&#x4E00;&#x4E9B;&#x4F7F;&#x7528;&#x603B;&#x7ED3;">&#x5173;&#x4E8E;AppleScript&#x811A;&#x672C;&#x8BED;&#x8A00;&#x7684;&#x4E00;&#x4E9B;&#x4F7F;&#x7528;&#x603B;&#x7ED3;</h1>
<ul>
<li><a href="#1-&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x5207;&#x6362;">1. &#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x5207;&#x6362;</a></li>
<li><a href="#2-&#x53D1;&#x9001;&#x90AE;&#x4EF6;">2. &#x53D1;&#x9001;&#x90AE;&#x4EF6;</a></li>
<li><a href="#3-&#x5F39;&#x7A97;&#x76F8;&#x5173;">3. &#x5F39;&#x7A97;&#x76F8;&#x5173;</a><ul>
<li><a href="#a-&#x666E;&#x901A;&#x5F39;&#x7A97;">a. &#x666E;&#x901A;&#x5F39;&#x7A97;</a></li>
<li><a href="#b-&#x5E26;&#x56FE;&#x6807;&#x7684;&#x5F39;&#x7A97;">b. &#x5E26;&#x56FE;&#x6807;&#x7684;&#x5F39;&#x7A97;</a></li>
<li><a href="#c-&#x5F39;&#x7A97;&#x8F93;&#x5165;&#x6846;&#x8868;&#x5355;">c. &#x5F39;&#x7A97;&#x8F93;&#x5165;&#x6846;&#x8868;&#x5355;</a></li>
<li><a href="#d-&#x9009;&#x62E9;&#x5217;&#x8868;&#x5F39;&#x7A97;">d. &#x9009;&#x62E9;&#x5217;&#x8868;&#x5F39;&#x7A97;</a></li>
<li><a href="#e-&#x9009;&#x62E9;&#x6587;&#x4EF6;&#x548C;&#x76EE;&#x5F55;">e. &#x9009;&#x62E9;&#x6587;&#x4EF6;&#x548C;&#x76EE;&#x5F55;</a></li>
</ul>
</li>
<li><a href="#4-&#x901A;&#x77E5;">4. &#x901A;&#x77E5;</a></li>
<li><a href="#5-shell-&#x8C03;&#x7528;-applescript">5. Shell &#x8C03;&#x7528; AppleScript</a></li>
<li><a href="#6-applescript-&#x8C03;&#x7528;-shell">6. AppleScript &#x8C03;&#x7528; Shell</a></li>
<li><a href="#&#x603B;&#x7ED3;">&#x603B;&#x7ED3;</a></li>
<li><a href="#&#x53C2;&#x8003;&#x535A;&#x6587;&#x6587;&#x7AE0;">&#x53C2;&#x8003;&#x535A;&#x6587;&#x6587;&#x7AE0;</a></li>
</ul>
<h2 id="1-&#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x5207;&#x6362;">1. &#x6697;&#x9ED1;&#x6A21;&#x5F0F;&#x5207;&#x6362;</h2>
<pre class="language-"><code class="lang-apl">tell application &quot;System Events&quot;
    tell appearance preferences
        set dark mode to not dark mode
    end tell
end tell
</code></pre>
<h2 id="2-&#x53D1;&#x9001;&#x90AE;&#x4EF6;">2. &#x53D1;&#x9001;&#x90AE;&#x4EF6;</h2>
<pre class="language-"><code class="lang-apl"><span class="token function">-</span><span class="token function">-</span>&#x8BBE;&#x7F6E;&#x53C2;&#x6570;
set recipientName to &quot;xxx&quot; <span class="token function">-</span><span class="token function">-</span>&#x6536;&#x4EF6;&#x4EBA;
set recipientAddress to &quot;xxx<span class="token dyadic-operator operator">@</span>gmail<span class="token dyadic-operator operator">.</span>com&quot; <span class="token function">-</span><span class="token function">-</span>&#x6536;&#x4EF6;&#x5730;&#x5740;
set mailSubject to &quot;&#x4F7F;&#x7528;AppleScript&#x811A;&#x672C;&#x81EA;&#x52A8;&#x5316;&#x53D1;&#x90AE;&#x4EF6;&quot; <span class="token function">-</span><span class="token function">-</span>&#x90AE;&#x4EF6;&#x4E3B;&#x9898;
set mailContent to &quot;&#x8FD9;&#x662F;&#x4E00;&#x5C01;&#x6765;&#x81EA;AppleScript&#x53D1;&#x51FA;&#x7684;&#x6D4B;&#x8BD5;&#x90AE;&#x4EF6;<span class="token function">,</span>&#x8BF7;&#x52FF;&#x56DE;&#x590D;<span class="token function">!</span><span class="token function">!</span><span class="token function">!</span>&quot; <span class="token function">-</span><span class="token function">-</span>&#x90AE;&#x4EF6;&#x5185;&#x5BB9;

<span class="token function">-</span><span class="token function">-</span>&#x6267;&#x884C;&#x53D1;&#x9001;&#x90AE;&#x4EF6;&#x64CD;&#x4F5C;
tell application &quot;Mail&quot;

    <span class="token function">-</span><span class="token function">-</span>&#x521B;&#x5EFA;&#x4FE1;&#x606F;
    set theMessage to make new outgoing message with properties <span class="token dfn builtin">{</span>subject<span class="token dfn builtin">:</span>mailSubject<span class="token function">,</span> content<span class="token dfn builtin">:</span>mailContent<span class="token function">,</span> visible<span class="token dfn builtin">:</span>true<span class="token dfn builtin">}</span>

    <span class="token function">-</span><span class="token function">-</span>&#x53D1;&#x9001;&#x4FE1;&#x606F;
    tell theMessage
        make new to recipient with properties <span class="token dfn builtin">{</span>name<span class="token dfn builtin">:</span>recipientName<span class="token function">,</span> address<span class="token dfn builtin">:</span>recipientAddress<span class="token dfn builtin">}</span>

        send

    end tell
end tell
</code></pre>
<h2 id="3-&#x5F39;&#x7A97;&#x76F8;&#x5173;">3. &#x5F39;&#x7A97;&#x76F8;&#x5173;</h2>
<p>&#x4E00;&#x4E2A;&#x6309;&#x94AE;&#x9ED8;&#x8BA4;&#x6837;&#x5F0F;
<img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/btn1s.png" alt="&#x4E00;&#x4E2A;&#x6309;&#x94AE;">
&#x4E00;&#x4E2A;&#x6309;&#x94AE;&#x52A0;&#x7A7A;&#x683C;&#x683C;&#x5F0F;&#x5316;&#x6837;&#x5F0F;
<img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/btn1l.png" alt="">
&#x4E24;&#x4E2A;&#x6309;&#x94AE;&#x6837;&#x5F0F;
<img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/btn2.png" alt="">
&#x4E09;&#x4E2A;&#x6309;&#x94AE;&#x6837;&#x5F0F;
<img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/btn3.png" alt="">
&#x6CA1;&#x6709;icon&#x6837;&#x5F0F; 
<img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/Xnip2021-01-23_22-02-53.png" alt=""></p>
<p>&#x53CD;&#x6B63;&#x8FD9;&#x4E2A;dialog&#x611F;&#x89C9;&#x5C31;&#x5F88;&#x5B89;&#x5353;</p>
<h4 id="a-&#x666E;&#x901A;&#x5F39;&#x7A97;">a. &#x666E;&#x901A;&#x5F39;&#x7A97;</h4>
<pre class="language-"><code class="lang-apl">display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; <span class="token function">-</span><span class="token function">-</span>&#x9ED8;&#x8BA4;&#x5E26;&#x4E0A;&#x53D6;&#x6D88;&#x548C;&#x786E;&#x8BA4;&#x6309;&#x94AE;
<span class="token function">-</span><span class="token function">-</span>&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;OK&#x6309;&#x94AE;&#x4EE5;&#x53CA;&#x9ED8;&#x8BA4;&#x9009;&#x4E2D;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons &quot;OK&quot; default button &quot;OK&quot;
<span class="token function">-</span><span class="token function">-</span>&#x6548;&#x679C;&#x540C;&#x4E0A;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons &quot;OK&quot; default button <span class="token number">1</span>
<span class="token function">-</span><span class="token function">-</span> &#x81EA;&#x5B9A;&#x4E49;&#x591A;&#x4E2A;&#x6309;&#x94AE; <span class="token punctuation">(</span>&#x6700;&#x591A;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x4E09;&#x4E2A;&#x6309;&#x94AE;&#x3002;<span class="token punctuation">)</span>
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons <span class="token dfn builtin">{</span>&quot;OK&quot;<span class="token function">,</span>&quot;Cancel&quot;<span class="token function">,</span>&quot;HAHA&quot;<span class="token dfn builtin">}</span> default button &quot;OK&quot;
</code></pre>
<p>&#x6216;&#x8005;alert &#x8FD9;&#x4E2A;&#x5C31;&#x6BD4;&#x8F83;iOS
<img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/alertl.png" alt=""></p>
<pre class="language-"><code class="lang-apl"><span class="token function">-</span><span class="token function">-</span> &#x4E0E; dialog &#x7C7B;&#x4F3C;&#x5E03;&#x5C40;&#x4E0A;&#x6709;&#x6240;&#x4E0D;&#x540C;<span class="token function">,</span>&#x6309;&#x94AE;&#x662F;&#x5C45;&#x4E2D;&#x7EB5;&#x5411;&#x6392;&#x5217;
display alert &quot;hahhaha&quot; buttons <span class="token dfn builtin">{</span>&quot;OK&quot;<span class="token function">,</span> &quot;NO&quot;<span class="token function">,</span> &quot;YES&quot;<span class="token dfn builtin">}</span> default button <span class="token number">2</span>
</code></pre>
<h4 id="b-&#x5E26;&#x56FE;&#x6807;&#x7684;&#x5F39;&#x7A97;">b. &#x5E26;&#x56FE;&#x6807;&#x7684;&#x5F39;&#x7A97;</h4>
<pre class="language-"><code class="lang-apl"><span class="token function">-</span><span class="token function">-</span>&#x53EF;&#x4EE5;&#x6307;&#x5B9A;&#x5BF9;&#x8BDD;&#x6846;&#x7684;&#x56FE;&#x6807;&#xFF0C;icon &#x56FE;&#x6807;&#x53EF;&#x4EE5;&#x6307;&#x5B9A; note <span class="token punctuation">(</span>&#x666E;&#x901A;<span class="token punctuation">)</span> <span class="token monadic-operator operator">/</span>stop <span class="token punctuation">(</span>&#x5371;&#x9669;<span class="token punctuation">)</span> <span class="token monadic-operator operator">/</span>caution <span class="token punctuation">(</span>&#x8B66;&#x544A;<span class="token punctuation">)</span> &#x4E09;&#x79CD;&#x7C7B;&#x578B; &#x6216;&#x8005;&#x6307;&#x5411;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons <span class="token dfn builtin">{</span>&quot;No&quot;<span class="token function">,</span> &quot;Yes&quot;<span class="token dfn builtin">}</span> default button &quot;Yes&quot; with icon caution

<span class="token function">-</span><span class="token function">-</span> &#x81EA;&#x5B9A;&#x4E49;&#x56FE;&#x6807; &#x6CE8;&#x610F;&#x56FE;&#x7247;&#x683C;&#x5F0F;&#x5E94;&#x8BE5;&#x4E3A;<span class="token dyadic-operator operator">.</span>icns&#x683C;&#x5F0F;&#x7684; &#x53EF;&#x4EE5;&#x53BB;&#x5E94;&#x7528;xx<span class="token dyadic-operator operator">.</span>app<span class="token monadic-operator operator">/</span>contens<span class="token monadic-operator operator">/</span>resources&#x4E0B;&#x9762;&#x53BB;&#x627E;
set fileName to choose file &quot;Select a Folder&quot;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons <span class="token dfn builtin">{</span>&quot;No&quot;<span class="token function">,</span> &quot;Yes&quot;<span class="token dfn builtin">}</span> default button &quot;Yes&quot; with icon file fileName

<span class="token function">-</span><span class="token function">-</span> &#x6307;&#x5B9A;&#x8DEF;&#x5F84; &#x684C;&#x9762;&#x8DEF;&#x5F84; <span class="token function">+</span> &#x6587;&#x4EF6;&#x540D;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons <span class="token dfn builtin">{</span>&quot;No&quot;<span class="token function">,</span> &quot;Yes&quot;<span class="token dfn builtin">}</span> default button &quot;Yes&quot; with icon file <span class="token punctuation">(</span><span class="token punctuation">(</span>path to desktop as text<span class="token punctuation">)</span> <span class="token monadic-operator operator">&amp;</span> &quot;AppIcon<span class="token dyadic-operator operator">.</span>icns&quot;<span class="token punctuation">)</span>

<span class="token function">-</span><span class="token function">-</span> &#x6216;&#x8005;&#x8FD9;&#x6837;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons <span class="token dfn builtin">{</span>&quot;No&quot;<span class="token function">,</span> &quot;Yes&quot;<span class="token dfn builtin">}</span> default button &quot;Yes&quot; with icon alias <span class="token punctuation">(</span><span class="token punctuation">(</span>path to desktop as text<span class="token punctuation">)</span> <span class="token monadic-operator operator">&amp;</span> &quot;AppIcon<span class="token dyadic-operator operator">.</span>icns&quot;<span class="token punctuation">)</span>
<span class="token function">-</span><span class="token function">-</span> &#x8F6C;&#x5316;&#x4E00;&#x4E0B;
<span class="token function">-</span><span class="token function">-</span> set fileName to <span class="token punctuation">(</span><span class="token punctuation">(</span>path to desktop as text<span class="token punctuation">)</span> <span class="token monadic-operator operator">&amp;</span> &quot;AppIcon<span class="token dyadic-operator operator">.</span>icns&quot;<span class="token punctuation">)</span>
set fileName to &quot;Macintosh HD<span class="token statement">:Users</span><span class="token dfn builtin">:</span>wangguibin<span class="token statement">:Desktop</span><span class="token statement">:AppIcon</span><span class="token dyadic-operator operator">.</span>icns&quot;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons <span class="token dfn builtin">{</span>&quot;No&quot;<span class="token function">,</span> &quot;Yes&quot;<span class="token dfn builtin">}</span> default button &quot;Yes&quot; with icon file fileName

<span class="token function">-</span><span class="token function">-</span> &#x76F4;&#x63A5;&#x4F7F;&#x7528;App Store&#x7684;&#x56FE;&#x6807;
set fileName to &quot;Macintosh HD<span class="token statement">:System</span><span class="token statement">:Applications</span><span class="token statement">:App</span> Store<span class="token dyadic-operator operator">.</span>app<span class="token statement">:Contents</span><span class="token statement">:Resources</span><span class="token statement">:AppIcon</span><span class="token dyadic-operator operator">.</span>icns&quot;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons <span class="token dfn builtin">{</span>&quot;No&quot;<span class="token function">,</span> &quot;Yes&quot;<span class="token dfn builtin">}</span> default button &quot;Yes&quot; with icon file fileName
</code></pre>
<h4 id="c-&#x5F39;&#x7A97;&#x8F93;&#x5165;&#x6846;&#x8868;&#x5355;">c. &#x5F39;&#x7A97;&#x8F93;&#x5165;&#x6846;&#x8868;&#x5355;</h4>
<pre class="language-"><code class="lang-apl">display dialog &quot;&#x8868;&#x5355;&quot; default answer &quot;&#x8F93;&#x5165;&#x6846;&#x5185;&#x5BB9;&quot; buttons <span class="token dfn builtin">{</span>&quot;&#x6309;&#x94AE;<span class="token number">1</span>&quot;<span class="token function">,</span> &quot;&#x6309;&#x94AE;<span class="token number">2</span>&quot;<span class="token function">,</span> &quot;&#x6309;&#x94AE;<span class="token number">3</span>&quot;<span class="token dfn builtin">}</span> default button <span class="token number">1</span> with icon caution
copy the result as list to <span class="token dfn builtin">{</span>text_returned<span class="token function">,</span> button_pressed<span class="token dfn builtin">}</span> <span class="token function">-</span><span class="token function">-</span>&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x5217;&#x8868;<span class="token dfn builtin">{</span>&#x6587;&#x672C;<span class="token function">,</span>&#x6309;&#x94AE;<span class="token dfn builtin">}</span>
</code></pre>
<h4 id="d-&#x9009;&#x62E9;&#x5217;&#x8868;&#x5F39;&#x7A97;">d. &#x9009;&#x62E9;&#x5217;&#x8868;&#x5F39;&#x7A97;</h4>
<p><img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/selecScriptList.png" alt=""></p>
<pre class="language-"><code class="lang-apl"><span class="token function">-</span><span class="token function">-</span> &#x9ED8;&#x8BA4;&#x5355;&#x9009; &#x9ED8;&#x8BA4;&#x4E0D;&#x9009;&#x4E2D;&#x7684;&#x8BDD;&#x76F4;&#x63A5;&#x8BBE;&#x7F6E; `default items <span class="token dfn builtin">{</span><span class="token dfn builtin">}</span>` &#x5373;&#x53EF;
choose from list <span class="token dfn builtin">{</span>&quot;Shell&quot;<span class="token function">,</span> &quot;Ruby&quot;<span class="token function">,</span> &quot;Python&quot;<span class="token function">,</span> &quot;Applescript&quot;<span class="token function">,</span> &quot;Javascript&quot;<span class="token function">,</span> &quot;Perl&quot;<span class="token function">,</span> &quot;Dart&quot;<span class="token dfn builtin">}</span> with title &quot;&#x65E5;&#x671F;&#x9009;&#x62E9;&quot; with prompt &quot;&#x9009;&#x62E9;&#x4E00;&#x95E8;&#x811A;&#x672C;&#x8BED;&#x8A00;&quot; OK button name &quot;&#x5B66;&#x4E60;&quot; cancel button name &quot;&#x653E;&#x5F03;&quot; default items <span class="token dfn builtin">{</span>&quot;Python&quot;<span class="token dfn builtin">}</span>

<span class="token function">-</span><span class="token function">-</span> &#x591A;&#x9009;
choose from list <span class="token dfn builtin">{</span>&quot;Sunday&quot;<span class="token function">,</span> &quot;Monday&quot;<span class="token function">,</span> &quot;Tuesday&quot;<span class="token function">,</span> &quot;Wednesday&quot;<span class="token function">,</span> &quot;Thursday&quot;<span class="token function">,</span> &quot;Friday&quot;<span class="token function">,</span> &quot;Saturday&quot;<span class="token dfn builtin">}</span> with title &quot;&#x65E5;&#x671F;&#x9009;&#x62E9;&quot; with prompt &quot;&#x9009;&#x62E9;&#x4E00;&#x5929;&#x6216;&#x8005;&#x591A;&#x5929;&quot; OK button name &quot;&#x786E;&#x8BA4;&#x9009;&#x62E9;&quot; cancel button name &quot;&#x4E0D;&#x9009;&quot; default items <span class="token dfn builtin">{</span>&quot;Monday&quot;<span class="token dfn builtin">}</span> with multiple selections allowed
</code></pre>
<h4 id="e-&#x9009;&#x62E9;&#x6587;&#x4EF6;&#x548C;&#x76EE;&#x5F55;">e. &#x9009;&#x62E9;&#x6587;&#x4EF6;&#x548C;&#x76EE;&#x5F55;</h4>
<p>&#x9009;&#x62E9;&#x6587;&#x4EF6;</p>
<pre class="language-"><code class="lang-apl"><span class="token function">-</span><span class="token function">-</span> &#x9009;&#x62E9;&#x6587;&#x4EF6; &#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x540D; &#x6CA1;&#x6709;&#x7684;&#x8BDD;&#x4E0D;&#x4F1A;&#x521B;&#x5EFA; &#x53EA;&#x662F;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x8DEF;&#x5F84; 
choose file name with prompt &quot;&#x83B7;&#x53D6;&#x6587;&#x4EF6;&#x540D;&quot;
</code></pre>
<p>&#x9009;&#x62E9;&#x76EE;&#x5F55;</p>
<pre class="language-"><code class="lang-apl"><span class="token function">-</span><span class="token function">-</span> &#x6CE8;&#xFF1A;&#x5176;&#x4E2D;prompt&#x548C;default location&#x53C2;&#x6570;&#x540C;Choose File Name<span class="token punctuation">;</span>&#x53E6;&#x5916;invisibles&#x6307;&#x5B9A;&#x663E;&#x793A;&#x9690;&#x85CF; &#x6587;&#x4EF6;<span class="token function">,</span>multiple selections allowed&#x53EF;&#x4EE5;&#x591A;&#x9009;<span class="token function">,</span>showing package contents&#x663E;&#x793A;&#x5305;&#x5185;&#x5BB9;<span class="token function">,</span>&#x7701;&#x7565;&#x65F6; &#x5219;&#x4E0D;&#x663E;&#x793A;&#x9690;&#x85CF;&#x6587;&#x4EF6;<span class="token monadic-operator operator">/</span>&#x4E0D;&#x53EF;&#x591A;&#x9009;<span class="token monadic-operator operator">/</span>&#x4E0D;&#x663E;&#x793A;&#x5305;&#x5185;&#x5BB9;
choose folder with prompt &quot;&#x9009;&#x62E9;&#x76EE;&#x5F55;&quot; default location file &quot;Macintosh HD<span class="token statement">:Users</span><span class="token dfn builtin">:</span>mac<span class="token statement">:Desktop</span>&quot; with invisibles<span class="token function">,</span> multiple selections allowed and showing package contents
</code></pre>
<h2 id="4-&#x901A;&#x77E5;">4. &#x901A;&#x77E5;</h2>
<p><img src="https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/notepng.png" alt=""></p>
<pre class="language-"><code class="lang-apl"><span class="token function">-</span><span class="token function">-</span> &#x58F0;&#x97F3;&#x6587;&#x4EF6;&#x90FD;&#x5728;<span class="token monadic-operator operator">/</span>System<span class="token monadic-operator operator">/</span>Library<span class="token monadic-operator operator">/</span>Sounds 
<span class="token function">-</span><span class="token function">-</span> &#x5176;&#x4E2D;Funk <span class="token function">,</span> Glass<span class="token function">,</span> Ping &#x8FD9;&#x51E0;&#x79CD;&#x597D;&#x542C;&#x4E00;&#x4E9B; 
display notification &quot;&#x901A;&#x77E5;&#x5185;&#x5BB9;&#x901A;&#x77E5;&#x5185;&#x5BB9;&#x901A;&#x77E5;&#x5185;&#x5BB9;&#x901A;&#x77E5;&#x5185;&#x5BB9;&quot; with title &quot;&#x901A;&#x77E5;&#x4E3B;&#x6807;&#x9898;&quot; subtitle &quot;&#x526F;&#x6807;&#x9898;&quot; sound name &quot;Funk&quot;
</code></pre>
<h2 id="5-shell-&#x8C03;&#x7528;-applescript">5. Shell &#x8C03;&#x7528; AppleScript</h2>
<p>&#x9002;&#x5408;&#x7B80;&#x77ED;&#x7684;&#x811A;&#x672C;&#x8BED;&#x53E5;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment">#&#x6CE8;&#x610F;&#x5355;&#x5F15;&#x53F7;shell&#x65E0;&#x6CD5;&#x4F20;&#x53C2; &#x5982;&#x9700;&#x4F20;&#x53C2;&#x5219;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x53CC;&#x5F15;&#x53F7;\&#x8F6C;&#x4E49;</span>
osascript -e <span class="token string">&apos;display notification &quot;&#x901A;&#x77E5;&#x5185;&#x5BB9;&#x901A;&#x77E5;&#x5185;&#x5BB9;&#x901A;&#x77E5;&#x5185;&#x5BB9;&#x901A;&#x77E5;&#x5185;&#x5BB9;&quot; with title &quot;&#x901A;&#x77E5;&#x4E3B;&#x6807;&#x9898;&quot; subtitle &quot;&#x526F;&#x6807;&#x9898;&quot; sound name &quot;Funk&quot;&apos;</span>
</code></pre>
<p>&#x9002;&#x5408;&#x591A;&#x884C;&#x811A;&#x672C;,&#x589E;&#x52A0;&#x53EF;&#x8BFB;&#x6027;</p>
<pre class="language-"><code class="lang-bash"><span class="token comment">#&#x7B80;&#x5355;&#x7C97;&#x66B4; &#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x91CD;&#x5B9A;&#x5411;&#x5305;&#x542B;applescript&#x8BED;&#x53E5;&#x5373;&#x53EF;</span>
osascript <span class="token operator">&lt;&lt;</span><span class="token string">EOF
set fileName to &quot;Macintosh HD:System:Applications:App Store.app:Contents:Resources:AppIcon.icns&quot;
display dialog &quot;&#x8FD9;&#x662F;&#x5185;&#x5BB9;&quot; with title &quot;&#x8FD9;&#x662F;&#x6807;&#x9898;&quot; buttons {&quot;No&quot;, &quot;Yes&quot;} default button &quot;Yes&quot; with icon file fileName
set btn to (button returned of result)
get btn
EOF</span>
<span class="token comment"># &#x8FD4;&#x56DE;&#x503C; &quot;NO&quot;&#x6216;&#x8005;&quot;OK&quot;</span>
</code></pre>
<p><strong>&#x66F4;&#x65B0;&#x4E8E;2021-01-26 20:50:50</strong>
&#x5C01;&#x88C5;&#x597D;&#x4E86;&#x4E00;&#x4E2A;shell&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x5F39;&#x7A97;,&#x53EF;&#x4EE5;&#x628A;&#x5B83;&#x5F53;&#x505A;&#x662F;&#x4E00;&#x4E2A;GUI&#x5DE5;&#x5177;,&#x7528;&#x4E8E;&#x63D0;&#x793A;/&#x63D0;&#x9192;&#x505A;&#x4EA4;&#x4E92;</p>
<pre class="language-"><code class="lang-bash"><span class="token shebang important">#!/bin/bash</span>

<span class="token comment"># 1. &#x81EA;&#x5B9A;&#x4E49;&#x901A;&#x77E5;&#x6D88;&#x606F; </span>
<span class="token comment"># &#x4F20;&#x53C2; $1:&#x6D88;&#x606F;&#x63CF;&#x8FF0; $2:&#x901A;&#x77E5;&#x6807;&#x9898; $3:&#x901A;&#x77E5;&#x526F;&#x6807;&#x9898;</span>
<span class="token keyword">function</span> <span class="token function-name function">showNoteMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  osascript -e <span class="token string">&quot;display notification <span class="token entity" title="\&quot;">\&quot;</span><span class="token variable">${1}</span><span class="token entity" title="\&quot;">\&quot;</span> with title <span class="token entity" title="\&quot;">\&quot;</span><span class="token variable">${2}</span><span class="token entity" title="\&quot;">\&quot;</span> subtitle <span class="token entity" title="\&quot;">\&quot;</span><span class="token variable">${3}</span><span class="token entity" title="\&quot;">\&quot;</span> sound name <span class="token entity" title="\&quot;">\&quot;</span>Funk<span class="token entity" title="\&quot;">\&quot;</span>&quot;</span>
<span class="token punctuation">}</span>
<span class="token comment">#test case:</span>
<span class="token comment">#showNoteMessage &quot;&#x6D88;&#x606F;&#x5185;&#x5BB9;&quot; &quot;&#x901A;&#x77E5;&quot; &quot;&#x901A;&#x77E5;&#x526F;&#x6807;&#x9898;&quot;</span>

<span class="token comment"># 2. &#x81EA;&#x5B9A;&#x4E49;&#x5F39;&#x7A97;(&#x7EDF;&#x4E00;&#x901A;&#x7528;&#x65B9;&#x6CD5;)</span>
<span class="token comment"># &#x4F20;&#x53C2;$1 &#x5F39;&#x7A97;&#x6D88;&#x606F;&#x5185;&#x5BB9;</span>
<span class="token comment"># &#x4F20;&#x53C2;$2 &#x5F39;&#x7A97;&#x6807;&#x9898;</span>
<span class="token comment"># &#x4F20;&#x53C2;$3 &#x6309;&#x94AE;&#x6807;&#x9898;,&#x591A;&#x4E2A;&#x7528;&#x82F1;&#x6587;&#x9017;&#x53F7;&#x9694;&#x5F00; </span>
<span class="token comment"># &#x4F20;&#x53C2;$4 &#x9ED8;&#x8BA4;&#x9009;&#x4E2D;&#x7684;&#x6309;&#x94AE;&#x6807;&#x9898;&#x6216;&#x8005;&#x6309;&#x94AE;&#x6570;&#x5B57;&#x4E0B;&#x6807;</span>
<span class="token comment"># &#x4F20;&#x53C2;$5 &#x662F;&#x5426;&#x4E3A;&#x8F93;&#x5165;&#x6846;&#x7C7B;&#x578B; &#x4F20;&quot;0&quot;&#x6216;&#x8005;&quot;1&quot; &#x9ED8;&#x8BA4;&quot;0&quot;</span>
<span class="token comment"># &#x4F20;&#x53C2;$6 &#x8F93;&#x5165;&#x6846;&#x9ED8;&#x8BA4;&#x5360;&#x4F4D;&#x5185;&#x5BB9;,&#x4F20;&#x4E0D;&#x4F20;&#x65E0;&#x6240;&#x8C13;,&#x9ED8;&#x8BA4;&#x4E3A;&#x7A7A;&#x5B57;&#x7B26;&#x4E32; &quot;&quot;</span>
<span class="token comment"># &#x4F20;&#x53C2;$7 &#x9ED8;&#x8BA4;&#x56FE;&#x6807;note/stop/caution &#x6216;&#x8005;&#x81EA;&#x5B9A;&#x4E49;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;(:&#x683C;&#x5F0F;&#x8DEF;&#x5F84;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;choose file&#x83B7;&#x53D6;)  </span>
<span class="token comment"># tips: &#x91CD;&#x8981;! &#x5982;&#x679C;&#x4E3A;&#x8F93;&#x5165;&#x6846;&#x6A21;&#x5F0F;,&#x90A3;&#x4E48;&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x5C31;&#x662F;{button returned:button,text returned:text} &#x5426;&#x5219;&#x53EA;&#x6709;&#x6309;&#x94AE;&#x6216;&#x8005;false </span>
<span class="token keyword">function</span> <span class="token function-name function">showCustomAlertMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>

<span class="token keyword">if</span> <span class="token punctuation">[</span><span class="token punctuation">[</span> -n <span class="token string">&quot;<span class="token variable">$4</span>&quot;</span> <span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>

    <span class="token keyword">if</span> <span class="token punctuation">[</span><span class="token punctuation">[</span> <span class="token variable">${4}</span> <span class="token operator">==</span> *<span class="token punctuation">[</span><span class="token operator">!</span><span class="token number">0</span>-9<span class="token punctuation">]</span>* <span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>
         <span class="token assign-left variable">defaultButton</span><span class="token operator">=</span><span class="token string">&quot;default button <span class="token entity" title="\&quot;">\&quot;</span><span class="token variable">${4}</span><span class="token entity" title="\&quot;">\&quot;</span>&quot;</span>
         <span class="token keyword">else</span>
         <span class="token assign-left variable">defaultButton</span><span class="token operator">=</span><span class="token string">&quot;default button <span class="token variable">${4}</span>&quot;</span>
    <span class="token keyword">fi</span>
<span class="token keyword">else</span>
    <span class="token assign-left variable">defaultButton</span><span class="token operator">=</span><span class="token string">&quot;&quot;</span>
<span class="token keyword">fi</span>

<span class="token comment">#&#x662F;&#x5426;&#x4E3A;&#x8F93;&#x5165;&#x6846;&#x6A21;&#x5F0F;</span>
<span class="token keyword">if</span> <span class="token punctuation">[</span><span class="token punctuation">[</span> <span class="token string">&quot;<span class="token variable">$5</span>&quot;</span> <span class="token operator">=</span> <span class="token string">&quot;1&quot;</span> <span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>
    <span class="token assign-left variable">IS_InputMode</span><span class="token operator">=</span><span class="token string">&quot;default answer <span class="token entity" title="\&quot;">\&quot;</span><span class="token variable">${6}</span><span class="token entity" title="\&quot;">\&quot;</span>&quot;</span>
    <span class="token assign-left variable">ReturnValue</span><span class="token operator">=</span><span class="token string">&quot;get result&quot;</span>
<span class="token keyword">else</span>
    <span class="token assign-left variable">IS_InputMode</span><span class="token operator">=</span><span class="token string">&quot;&quot;</span>
    <span class="token assign-left variable">ReturnValue</span><span class="token operator">=</span><span class="token string">&quot;get the button returned of the result&quot;</span>
<span class="token keyword">fi</span>

<span class="token keyword">if</span> <span class="token punctuation">[</span><span class="token punctuation">[</span> -n <span class="token string">&quot;<span class="token variable">$7</span>&quot;</span> <span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>
  <span class="token keyword">case</span> <span class="token variable">${7}</span> <span class="token keyword">in</span>
    note<span class="token punctuation">)</span>
    <span class="token assign-left variable">ICON</span><span class="token operator">=</span><span class="token string">&quot;with icon note&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
    stop<span class="token punctuation">)</span>
    <span class="token assign-left variable">ICON</span><span class="token operator">=</span><span class="token string">&quot;with icon stop&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
    caution<span class="token punctuation">)</span>
    <span class="token assign-left variable">ICON</span><span class="token operator">=</span><span class="token string">&quot;with icon caution&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
    *<span class="token punctuation">)</span>
    <span class="token assign-left variable">ICON</span><span class="token operator">=</span><span class="token string">&quot;with icon file <span class="token entity" title="\&quot;">\&quot;</span><span class="token variable">${7}</span><span class="token entity" title="\&quot;">\&quot;</span>&quot;</span>
    <span class="token punctuation">;</span><span class="token punctuation">;</span>
 <span class="token keyword">esac</span>
<span class="token keyword">else</span>
 <span class="token assign-left variable">ICON</span><span class="token operator">=</span><span class="token string">&quot;with icon file <span class="token entity" title="\&quot;">\&quot;</span>Macintosh HD:Applications:Xcode.app:Contents:Resources:Xcode.icns<span class="token entity" title="\&quot;">\&quot;</span>&quot;</span>
<span class="token keyword">fi</span>

osascript <span class="token operator">&lt;&lt;</span><span class="token string">EOF
    set buttonStr to &quot;<span class="token variable">${3}</span>&quot;
    set oldDelimiters to AppleScript&apos;s text item delimiters
    set AppleScript&apos;s text item delimiters to &quot;,&quot;
    set buttonList to every text item of buttonStr
    set AppleScript&apos;s text item delimiters to oldDelimiters
    get buttonList
    set btns to buttonList
    display dialog &quot;<span class="token variable">${1}</span>&quot; with title &quot;<span class="token variable">${2}</span>&quot; buttons btns <span class="token variable">${IS_InputMode}</span> <span class="token variable">${defaultButton}</span> <span class="token variable">${ICON}</span>
    <span class="token variable">${ReturnValue}</span>  
EOF</span>
<span class="token punctuation">}</span>

<span class="token comment"># showCustomAlertMessage &quot;&#x5F39;&#x7A97;&#x6D88;&#x606F;&#x5185;&#x5BB9;&quot; &quot;&#x5F39;&#x7A97;&#x6807;&#x9898;&quot; &quot;&#x6309;&#x94AE;1,&#x6309;&#x94AE;2,&#x6309;&#x94AE;3&quot; &quot;&#x6309;&#x94AE;2&quot;  &quot;1&quot; &quot;&#x5360;&#x4F4D;&#x5185;&#x5BB9;&quot; &quot;note&quot;</span>
<span class="token comment"># showCustomAlertMessage &quot;&#x5F39;&#x7A97;&#x6D88;&#x606F;&#x5185;&#x5BB9;&quot; &quot;&#x5F39;&#x7A97;&#x6807;&#x9898;&quot; &quot;&#x6309;&#x94AE;1,&#x6309;&#x94AE;2,&#x6309;&#x94AE;3&quot; &quot;&#x6309;&#x94AE;2&quot;  &quot;0&quot; &quot;&#x5360;&#x4F4D;&#x5185;&#x5BB9;&quot; &quot;note&quot;</span>
<span class="token comment">#showCustomAlertMessage &quot;&#x5F39;&#x7A97;&#x6D88;&#x606F;&#x5185;&#x5BB9;&quot; &quot;&#x5F39;&#x7A97;&#x6807;&#x9898;&quot; &quot;&#x6309;&#x94AE;1,&#x6309;&#x94AE;2,&#x6309;&#x94AE;3&quot; &quot;&#x6309;&#x94AE;2&quot; &quot;0&quot; &quot;&#x5360;&#x4F4D;&#x5185;&#x5BB9;&quot; &quot;stop&quot; </span>
<span class="token comment">#showCustomAlertMessage &quot;&#x5F39;&#x7A97;&#x6D88;&#x606F;&#x5185;&#x5BB9;&quot; &quot;&#x5F39;&#x7A97;&#x6807;&#x9898;&quot; &quot;&#x6309;&#x94AE;1,&#x6309;&#x94AE;2,&#x6309;&#x94AE;3&quot; &quot;&#x6309;&#x94AE;2&quot; &quot;0&quot; &quot;&#x5360;&#x4F4D;&#x5185;&#x5BB9;&quot; &quot;Macintosh HD:Applications:Xcode.app:Contents:Resources:Xcode.icns&quot;</span>

<span class="token comment"># &#x666E;&#x901A;&#x5F39;&#x7A97; &#x4E00;&#x4E2A;ok&#x5C31;&#x591F;&#x4E86; &#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x786E;&#x8BA4;&#x7684;&#x90A3;&#x79CD;</span>
<span class="token keyword">function</span> <span class="token function-name function">onlyConfirmButton</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    showCustomAlertMessage <span class="token string">&quot;<span class="token variable">$1</span>&quot;</span> <span class="token string">&quot;&#x6E29;&#x99A8;&#x63D0;&#x793A;&quot;</span> <span class="token string">&quot;&#x597D;&#x7684;&quot;</span> <span class="token number">1</span>
<span class="token punctuation">}</span> 
<span class="token comment">#onlyConfirmButton &quot;&#x767B;&#x5F55;&#x6210;&#x529F;!\n&#x5F39;&#x7A97;&#x6210;&#x529F;!&quot;</span>

<span class="token comment"># &#x591A;&#x6309;&#x94AE;&#x5F39;&#x7A97; &#x6700;&#x591A;&#x4E09;&#x4E2A;&#x6309;&#x94AE; &#x591A;&#x4E86;&#x4F1A;&#x62A5;&#x9519;</span>
<span class="token keyword">function</span> <span class="token function-name function">mostButtons</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    showCustomAlertMessage <span class="token string">&quot;<span class="token variable">$1</span>&quot;</span> <span class="token string">&quot;&#x6E29;&#x99A8;&#x63D0;&#x793A;&quot;</span> <span class="token string">&quot;&#x6309;&#x94AE;1,&#x6309;&#x94AE;2,&#x6309;&#x94AE;3&quot;</span> <span class="token string">&quot;&#x6309;&#x94AE;3&quot;</span>
<span class="token punctuation">}</span>
<span class="token comment">#mostButtons &quot;&#x6700;&#x591A;&#x53EA;&#x80FD;&#x5B9A;&#x4E49;&#x4E09;&#x4E2A;&#x6309;&#x94AE;&#x54E6;&quot;</span>

<span class="token comment"># &#x8F93;&#x5165;&#x6846;&#x5F39;&#x7A97;</span>
<span class="token keyword">function</span> <span class="token function-name function">showInputAlertMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    showCustomAlertMessage <span class="token string">&quot;<span class="token variable">$1</span>&quot;</span> <span class="token string">&quot;<span class="token variable">$2</span>&quot;</span> <span class="token string">&quot;&#x53D6;&#x6D88;,&#x786E;&#x8BA4;&quot;</span> <span class="token number">2</span> <span class="token string">&quot;1&quot;</span> <span class="token string">&quot;&quot;</span>
<span class="token punctuation">}</span>
showInputAlertMessage <span class="token string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x5BC6;&#x7801;&quot;</span> <span class="token string">&quot;&#x767B;&#x5F55;&#x9A8C;&#x8BC1;&quot;</span>
</code></pre>
<h2 id="6-applescript-&#x8C03;&#x7528;-shell">6. AppleScript &#x8C03;&#x7528; Shell</h2>
<p>do shell script + shell&#x811A;&#x672C;&#x8BED;&#x53E5;&#x5373;&#x53EF;</p>
<pre class="language-"><code class="lang-apl">set shellStr to do shell script &quot;cd <span class="token function">~</span><span class="token monadic-operator operator">/</span>Desktop<span class="token punctuation">;</span>cat shell_var<span class="token dyadic-operator operator">.</span>sh&quot;
display alert shellStr buttons <span class="token dfn builtin">{</span>&quot;OK&quot;<span class="token dfn builtin">}</span>
</code></pre>
<h2 id="&#x603B;&#x7ED3;">&#x603B;&#x7ED3;</h2>
<p><code>AppleScript</code>&#x914D;&#x5408;<code>Shell</code> &#x4EE5;&#x53CA;<code>Alfred</code> &#x611F;&#x89C9;&#x80FD;&#x73A9;&#x51FA;&#x5F88;&#x591A;&#x82B1;&#x6837;&#x6765;,&#x4E00;&#x4E9B;&#x5DE5;&#x5177;&#x786E;&#x5B9E;&#x80FD;&#x63D0;&#x5347;&#x4E0D;&#x5C11;&#x6548;&#x7387;&#x548C;&#x4F53;&#x9A8C;&#x3002;
 &#x6211;&#x5E73;&#x65F6;&#x73A9;&#x7684;&#x4E00;&#x4E9B;&#x5DE5;&#x5177;&#x5B58;&#x653E;&#x5728;&#x8FD9; <a href="https://github.com/WangGuibin/WGBToolsConfigRepository" target="_blank">https://github.com/WangGuibin/WGBToolsConfigRepository</a></p>
<h2 id="&#x53C2;&#x8003;&#x535A;&#x6587;&#x6587;&#x7AE0;">&#x53C2;&#x8003;&#x535A;&#x6587;&#x6587;&#x7AE0;</h2>
<ul>
<li><a href="https://www.exchen.net/applescript-&#x5FEB;&#x901F;&#x5165;&#x95E8;.html" target="_blank">applescript-&#x5FEB;&#x901F;&#x5165;&#x95E8;</a></li>
<li><a href="https://blog.csdn.net/u011238639/article/details/56506056" target="_blank">&#x6211;&#x7684;&#x65B0;&#x73A9;&#x5177;-AppleScript(&#x56DB;)</a></li>
<li><a href="https://www.cnblogs.com/itcomputer/p/10162392.html" target="_blank">applescript&#x5FEB;&#x901F;&#x5165;&#x95E8;&#x6559;&#x7A0B;</a></li>
<li><a href="https://lucifr.com/make-your-mac-sing-happy-birthday-with-applescript/" target="_blank">AppleScript &#x811A;&#x672C;&#x8BA9; Mac &#x5531;&#x751F;&#x65E5;&#x5FEB;&#x4E50;&#x6B4C;</a><hr><div id="vcomments"></div><script src="//unpkg.com/valine/dist/Valine.min.js"></script><script>new Valine({el: "#vcomments",appId: 'oT5vWHkWT1JN1o5aXiSqYGtH-gzGzoHsz',appKey: 'V7zBLpzBgxVESicbyF072Cj9',placeholder: 'Just go go',avatar: '',meta: undefined,pageSize: 10,lang: 'zh-CN',recordIP: false})</script> </li>
</ul>
<footer class="page-footer"><span class="copyright">CoderWGB all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x7AE0;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2021-01-31 20:59:02
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: AppleScript相关">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.html" class="navigation navigation-next " aria-label="Next page: 为Mac自带的AppleScript脚本编辑器增加代码注释快捷键">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"关于AppleScript脚本语言的一些使用总结","level":"1.3.1","depth":2,"next":{"title":"为Mac自带的AppleScript脚本编辑器增加代码注释快捷键","level":"1.3.2","depth":2,"path":"books/AppleScript/为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.md","ref":"./books/AppleScript/为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.md","articles":[]},"previous":{"title":"AppleScript相关","level":"1.3","depth":1,"path":"books/AppleScript/README.md","ref":"./books/AppleScript/README.md","articles":[{"title":"关于AppleScript脚本语言的一些使用总结","level":"1.3.1","depth":2,"path":"books/AppleScript/关于AppleScript脚本语言的一些使用总结.md","ref":"./books/AppleScript/关于AppleScript脚本语言的一些使用总结.md","articles":[]},{"title":"为Mac自带的AppleScript脚本编辑器增加代码注释快捷键","level":"1.3.2","depth":2,"path":"books/AppleScript/为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.md","ref":"./books/AppleScript/为Mac自带的AppleScript脚本编辑器增加代码注释快捷键.md","articles":[]},{"title":"say指令让Mac开口说话","level":"1.3.3","depth":2,"path":"books/AppleScript/say指令让Mac说话.md","ref":"./books/AppleScript/say指令让Mac说话.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["back-to-top-button","chapter-fold","code","copy-code-button","splitter","valine","-lunr","-search","search-pro","insert-logo","custom-favicon","pageview-count","tbfed-pagefooter","popup","-sharing","sharing-plus","-highlight","prism","prism-themes","simple-page-toc"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"CoderWGB","modify_label":"该文章修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"prism":{"css":["prism-themes/themes/prism-xonokai.css"]},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"splitter":{},"search-pro":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"popup":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"favicon":"./logo.ico","back-to-top-button":{},"pageview-count":{},"prism-themes":{},"custom-favicon":{},"copy-code-button":{},"sharing":{"qq":true,"all":["douban","facebook","google","instapaper","linkedin","twitter","weibo","messenger","qq","qzone","viber","whatsapp"],"douban":true,"facebook":true,"weibo":true,"twitter":true,"pocket":true,"google":true,"qzone":true},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"insert-logo":{"style":"background: none; max-height: 30px; min-height: 30px","url":"https://cdn.jsdelivr.net/gh/WangGuibin/MyFilesRepo/images/20210130164238.png"},"valine":{"avatar":"","lang":"zh-CN","pageSize":10,"placeholder":"Just go go","recordIP":false,"appId":"oT5vWHkWT1JN1o5aXiSqYGtH-gzGzoHsz","appKey":"V7zBLpzBgxVESicbyF072Cj9"}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Summary","gitbook":"*"},"file":{"path":"books/AppleScript/关于AppleScript脚本语言的一些使用总结.md","mtime":"2021-01-31T12:59:02.720Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-01-31T13:01:17.483Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

